#include <iostream>
#include <algorithm>
#include "TestSortHelper.h"
#include "SelectionSort.h"

using namespace std;

template <typename T>
void insertSort(T arrays[], int lenarray) {
	for (int i = 1; i < lenarray; i++) {
		/*for (int j = i; j > 0; j--) {
			if (arrays[j] < arrays[j-1]) {
				swap(arrays[j-1], arrays[j]);
			}
			else {
				break;
			}
		}*/

		T temple = arrays[i];
		int j = i;
		for (; j > 0 && temple <arrays[j-1];j--) {
			arrays[j] = arrays[j - 1];
		}
		arrays[j] = temple;

	}
}

int main(){
	int n = 10000;
	int *arr = TestSortHelper::generateRandomArray(n, 0, n);
	int *arr2 = TestSortHelper::copyIntArray(arr,n);
	TestSortHelper::testSort("selection Sort", selectionSort, arr, n);
	TestSortHelper::testSort("put Sort", insertSort, arr2, n);

	delete[] arr;
	delete[] arr2;

	int *arr1 = TestSortHelper::generateNearlyOrderedArray(n, 100);
	int *arr12 = TestSortHelper::copyIntArray(arr, n);
	TestSortHelper::testSort("selection Sort", selectionSort, arr1, n);
	TestSortHelper::testSort("put Sort", insertSort, arr12, n);

	delete[] arr1;
	delete[] arr12;
}